/*****************************************************************************
* Copyright (c) 2014,H.B.
* All rights reserved.
* 
* FileName : DtvFilter.java
* Description : define DtvFilter
* 
* Version : 0.0.0
* Author : HB   Reviewer : 
* Date : 2014-07-08
* Record : Create
*
* History : 
* (1) Version : 0.0.0
*     Author : HB   Reviewer : 
*     Date : 2014-07-08
*     Record : Create
****************************************************************************/

package hb.dtv;


public class DtvFilter
{

	final private int mJniPtr;

	DtvFilter(int ptr)
	{
		mJniPtr=ptr;
	}

	public void Release()
	{
		nativeRelease(mJniPtr);
	}

	public void AssociateChannel(DtvChannel channel)
	{
		nativeAssociateChannel(mJniPtr,channel.mJniPtr);
	}

	public void DisassociateChannel(DtvChannel channel)
	{
		nativeDisassociateChannel(mJniPtr,channel.mJniPtr);
	}

	public void SetParameter(byte[] mask,byte[] match,byte[] negate)
	{
		nativeSetParameter(mJniPtr,mask,match,negate);
	}


	@Override
	public boolean equals(Object o) 
	{
		 if (this == o) return true;
		 if (!(o instanceof DtvFilter)) return false;
		 DtvFilter d=(DtvFilter)o;
		 if(mJniPtr==d.mJniPtr)return true;
		 return nativeGetHandle(mJniPtr)==nativeGetHandle(d.mJniPtr);
	}

	@Override
	protected void finalize() throws Throwable
	{
		nativeDestroy(mJniPtr);
		super.finalize();
	}

	private native static void nativeAssociateChannel(int jniPtr,int channel);
	
	private native static void nativeDisassociateChannel(int jniPtr,int channel);
		
	private native static void nativeSetParameter(int jniPtr,
		byte[] mask,byte[] match,byte[] negate);
		
	private native static int nativeGetHandle(int jniPtr);
	
	private native static void nativeRelease(int jniPtr);
	
	private native static void nativeDestroy(int jniPtr);
}

